home *** CD-ROM | disk | FTP | other *** search
-
- ; $VER: ShapesFix.bb2 v1.1 (17.09.2000)
-
- ; Author: Damir Arh
- ; Thanks go to: David McMinn
- ; E-mail: damir.arh@telesat.si
- ; WWW: http://damir.gajba.net/
-
- ; This source code is completely free. You can redistribute
- ; and/or modify it without any restrictions whatsoever.
-
- ;-------------------------------------------------------------
-
- ; These two functions are meant as a replacement for the buggy
- ; commands CopyShape and Scale which trash the image when its
- ; size exceeds 32 KB. You can use these functions safely as
- ; long as the size of the single bitplane doesn't exceed 32 KB.
- ; In case it does you'll probably have to rewrite the blit
- ; functions, too.
-
- ; At the end of this source ('main' label) there's a small
- ; demo to show you how to use the functions. You can also
- ; easily check that the functions now work fine by compiling
- ; this program and loading a suitable image.
-
-
- ;-------------------------------------------------------------
- .FixedScale:
- ;-------------------------------------------------------------
-
- ; This function is meant as a replacement for the Scale command.
- ; Though it isn't used in exactly the same away. Unlike the Scale
- ; command it copies the shape at the same time as it scales it.
- ; By doing this the overhead is reduced to minimum as the
- ; underlying graphics.library function doesn't support scaling
- ; of the overlapping bitmaps. I also thing that such a function
- ; is of more use than the original one but if you need the
- ; original functionality, you shouldn't have any problems
- ; writing a suitable replacement.
-
- Statement FixedScaleCopy{source.b,destination.b,dummy.l,x.q,y.q}
-
- ; calculate the scaling factors
- x1.w=100*x
- destwidth.w = ScalerDiv_(ShapeWidth(source),x1,100)
- y1.w=100*y
- destheight.w = ScalerDiv_(ShapeHeight(source),y1,100)
-
- ; setup the destination shape
- *srcshp.shape = Addr Shape(source)
- InitShape destination,destwidth,destheight,*srcshp\_depth
- *destshp.shape = Addr Shape(destination)
-
- ; setup the needed bitmap structures
- DEFTYPE ._BitMap srcbmp, destbmp
- srcbmp\BytesPerRow = *srcshp\_ebwidth
- srcbmp\Rows = *srcshp\_pixheight
- srcbmp\_Depth = *srcshp\_depth
- For i.w=0 To *srcshp\_depth-1
- srcbmp\Planes[i] = *srcshp\_data + i * *srcshp\_ebwidth * *srcshp\_pixheight
- Next i
- destbmp\BytesPerRow = *destshp\_ebwidth
- destbmp\Rows = *destshp\_pixheight
- destbmp\_Depth = *destshp\_depth
- For i.w=0 To *destshp\_depth-1
- destbmp\Planes[i] = *destshp\_data + i * *destshp\_ebwidth * *destshp\_pixheight
- Next i
-
- ; setup the bitmap scale structure
- DEFTYPE .BitScaleArgs bsa
- bsa\bsa_SrcX = 0
- bsa\bsa_SrcY = 0
- bsa\bsa_SrcWidth = ShapeWidth(source)
- bsa\bsa_SrcHeight = ShapeHeight(source)
- bsa\bsa_XSrcFactor = 100
- bsa\bsa_XDestFactor = x1
- bsa\bsa_YSrcFactor = 100
- bsa\bsa_YDestFactor = y1
- bsa\bsa_SrcBitMap = &srcbmp
- bsa\bsa_DestBitMap = &destbmp
- bsa\bsa_Flags = 0
-
- ; preform the actual scaling
- BitMapScale_(&bsa)
- MakeCookie destination
-
- End Statement
-
-
- ;-------------------------------------------------------------
- .FixedCopy:
- ;-------------------------------------------------------------
-
- ; This function is an exact replacement for the CopyShape
- ; command. The functionality and the calling convention
- ; is exactly the same.
-
- Statement FixedCopyShape{source.b,destination.b}
- *srcshp.shape = Addr Shape(source)
- *dstshp.shape = Addr Shape(destination)
- InitShape destination,*srcshp\_pixwidth,*srcshp\_pixheight,*srcshp\_depth
- CopyMem_ *srcshp\_data, *dstshp\_data, *srcshp\_ebwidth * *srcshp\_pixheight * *dstshp\_depth
- MakeCookie destination
- End Statement
-
- ;-------------------------------------------------------------
- .main:
- ;-------------------------------------------------------------
-
- ; This is a short demonstration of the above functions. Try it
- ; out but there is no need to copy this to your program.
-
- Print "Filename: "
- filename$=Edit$(256)
-
- If Exists(filename$)=0 Then End
-
- ILBMInfo filename$
- width.l = ILBMWidth
- height.l = ILBMHeight
- dept.l = ILBMDepth
-
- InitShape 0,width,height,dept
- ShapesBitMap 0,1
- LoadBitMap 1,filename$
- LoadPalette 1,filename$
- MakeCookie 0
-
- Screen 0,0,0,640,512,8,$8004,"",1,1
- ScreensBitMap 0,0
- Use Palette 1
- Cls 0
-
- FixedCopyShape{0,1}
- ClipBlit 1,0,0
-
- MouseWait
-
- Cls 0
- FixedScaleCopy{0,1,0,0.5,0.5}
- ClipBlit 1,0,0
-
- MouseWait
-
- End
-
-